package ReflectionLearn.RefleDeepLearn;

import ReflectionLearn.RefleDeepLearnClass.Person;
import org.junit.jupiter.api.Test;


import java.lang.reflect.Constructor;

/**
 * @author Lenl
 * @version v1.0
 * @create 2021-06-07 20:08
 * @description 获取构造器结构
 *
 */
public class ConstructorTest {
    @Test
    public void test1(){
        Class clazz= Person.class;
        //获取当前运行时类中声明为public的构造器
        Constructor[] constructors=clazz.getConstructors();
        for (Constructor c:constructors){
            System.out.println(c);
        }
        System.out.println("****************");
        //获取当前运行时类的所有构造器
        Constructor[] constructors1=clazz.getDeclaredConstructors();
        for (Constructor c:constructors1){
            System.out.println(c);
        }
    }
}
